<%--
 *  File:    DeptSummary.jsp
 *  @Author: Hilldao 
 *  Date:    2001/11/4
 *
 *  Copyright (C) 2000 - 2001 Oval Technologies, Inc.
 *  All rights reserved. 
 *
 *  This software is the confidential and proprietary information of Oval 
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>     
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/oval-tag.tld" prefix="oval" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>

<% //--------------------------------------  setting logger --%>
<%
  	Category cat = Category.getInstance("jsp.DeptSummary");
%>

<%
  //init param
  String strModuleName = "OGM";
  String privilegeCode = "10102,L101";
  String contextPath = request.getContextPath();
%>



<%

  String strTableName = "ovdepartment";
  //get userinfo
  HashMap CurUserInfo = (HashMap)session.getAttribute("userinfo");
%>
<% //--------------------------------------  include files list --%>
<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>
<%@ include file="/rpt/ReportURL.inc"%>

<html>
<head>
<title>DeptSummary</title>
<PageFlow:CheckPageFlow pageName="deptsummary"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="../../css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="../../js/FuncLib.js"></script>
<%@ include file="/inc/SummaryDivision.inc" %>
<%
  cat.debug("The strCurSearchName is :" + strCurSearchName);
  cat.debug("The strCurSearchValue is :" + strCurSearchValue);  
  cat.debug("The strCurOrderByCol is :" + strCurOrderByCol);
  cat.debug("The strCurOrderByType is :" + strCurOrderByType);
  cat.debug("The nCurMaxItem is :" + nCurMaxItem);  
  cat.debug("The nCurCount is :" + nCurCount);  
  cat.debug("The nCurPageNo is :" + nCurPageNo);
  cat.debug("The nCurTotalPage is :" + nCurTotalPage);
  cat.debug("The nCurEndIndex is :" + nCurEndIndex);
  cat.debug("The bCurHasPre is :" + bCurHasPre);
  cat.debug("The bCurHasNext is :" + bCurHasNext);     
  cat.debug("The CurUserInfo is :" + CurUserInfo);       

  Vector deptSummary = (Vector)pageContext.getAttribute("deptsummary");
  
  if(deptSummary == null)
  {
    deptSummary = new Vector();
  }
  cat.debug("The deptSummary is :" + deptSummary);
  
  if(pageContext.getAttribute("orginfo") == null)
    pageContext.setAttribute("orginfo",new HashMap());
%>
<script>
function page_setOrg(id,name)
{
  document.deptsummaryform.orgid.value = id;
  document.deptsummaryform.orgname.value = name;
  page_summary('search');
}

function clickUserGroup(id,parid,Bottom,status)
{
  document.deptsummaryform.deptid.value = id;
  document.deptsummaryform.status.value = status;
  document.deptsummaryform.isBottom.value = Bottom; 
  document.deptsummaryform.parentdeptid.value = parid;
  parent.down.location.href ="<%= contextPath%>/Blank.jsp?<%= OvalTools.randomURL() %>";
}
function page_delete()
{
  var id = document.deptsummaryform.deptid.value;
  var isBottom = document.deptsummaryform.isBottom.value;
  if(isBottom=='N')
  {
     alert("<%= message.getMessageDesc("NOT_LEAF", label.getLabelName("L_Department",false))%>");
     return;
  }
  if(id == null || id.length == 0 || id == "" || id == "-1")
    return;
  var flag = confirm("<%= message.getMessageDesc("ARE_YOU_SURE_DEL")%>");
  if(!flag)
    return;
  document.deptsummaryform.actionname.value = "delete";
  isRunning = true;
  document.deptsummaryform.submit();
  
}
function page_edit()
{
  var uid = document.deptsummaryform.deptid.value;
  if(uid == null || uid.length == 0 || uid == "" || uid == "-1")
    return;
  parent.down.location.href = "DeptEdit.jsp?<%= OvalTools.randomURL() %>&deptid=" + uid + "&languagecode=<%= strLanguageCode %>&orgid=<oval:write name="orginfo" property="orgid"/>";
}

function create_child()
{
  if(deptsummaryform.status.value==28){
  	alert("无效的部门无法新建下级分组！");return;
  }
  var uid = document.deptsummaryform.deptid.value;
  if(uid == null || uid.length == 0 || uid == "" || uid == "-1")
    return;
  parent.down.location.href = "DeptEdit.jsp?<%= OvalTools.randomURL() %>&parentdeptid=" + uid + "&languagecode=<%= strLanguageCode %>&orgid=<oval:write name="orginfo" property="orgid"/>";
}
function page_summary(actionvalue,orderbyname)
{
  var editform = summaryPrepare(deptsummaryform,actionvalue,orderbyname);
  editform.action = "DeptSummary.jsp?<%= OvalTools.randomURL() %>";
  editform.target = "_self";
  isRunning = true;
  editform.submit();  
}
function poporg()
{
  window.open("OrgSelect.jsp?<%= OvalTools.randomURL() %>&selectoption=owner&languagecode=<%= strLanguageCode %>", "newwindow", "height=250, width=600,top=100,left=100,toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, status=no");
}
function exportExcel(){
	 window.open("<%= reportURL %>/servlet/ExcecuteReport/departmentmessagerReport.sox?__format=xlsx&__folder=/ovalreport");
	}

</script>
</head>

<body>
<% //--------------------------------------  page location --%>
	<%@ include file="/inc/PageLocation.inc" %>
<table width="100%" cellspacing="0" border="0" cellpadding="0">
 <form name="deptsummaryform" method="post" action="../../Dispatcher"  target="_parent">
    <input type="hidden" name="pagename" value="deptsummary">
    <input type="hidden" name="actionname">
    <input type="hidden" name="languagecode" value="<%= strLanguageCode %>">
    <oval:hidden name="orginfo" property="orgid"/>
    
  <tr>
    <td> 
      <table width="100%" border="0" cellspacing="0">  
        <tr> 
          <%if(privilegeSet != null && privilegeSet.contains("1000000")){%>    
          <td nowrap><%= label.getLabelName("L_OwnerOrg") + label.getLabelName("L_Colon") %>               
            	<input type="text" name="orgname" value="<oval:write name="orginfo" property="orgname"/>" size="30" readonly>
              <a onclick="poporg()"><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0"/></a> &nbsp;
              </td>
          <td>&nbsp;&nbsp;</td>
          <%}%>
          <td>
           <table>
         <%@ include file="/inc/SummarySearch.inc" %>
           </table>
          </td>
         </tr> 
       </table>
    </td>
  </tr>
  <tr> 
    <td> 
      <table width="100%" border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center">
         <tr  class="deepblue-left"> 
            <td width="5%" class="title_center">&nbsp;</td>
            <td width="12%" class="title_center"><a href="javascript:page_summary('orderby','deptcode')"><%= label.getLabelName("L_DeptCode") %></a></td>
            <td width="25%" class="title_center"><a href="javascript:page_summary('orderby','deptname')"><%= label.getLabelName("L_DeptName2") %></a></td>
            <td width="25%" class="title_center"><a href="javascript:page_summary('orderby','parentdeptname')"><%= label.getLabelName("L_ParentDept") %></a></td>
            
            <td class="title_center"><a href="javascript:page_summary('orderby','deptdesc')"><%= label.getLabelName("L_DeptDesc") %></a></td>
            <td class="title_center"><a href="javascript:page_summary('orderby','businessdeptdesc)"><%= label.getLabelName("L_BusinessDeptName") %></a></td>
            <td width="6%" class="title_center"><a href="javascript:page_summary('orderby','statusname')"><%= label.getLabelName("L_StatusName") %></a></td>
         </tr>
         <%
             int j = 0;
             String strClassType = new String(); 
             Integer nDefaultDeptId = new Integer(-1);  
             Integer nParentDeptId =  new Integer(-1);
             Integer nDefaultStatus =  new Integer(-1);
             String DefaultIsBottom = "Y";       
             boolean bHasChecked = false;
          %>
          <logic:iterate id="dept" collection="<%= deptSummary %>">                      
         <%
            HashMap deptMap = (HashMap)pageContext.getAttribute("dept"); 
            String deptName = (String)deptMap.get("deptname");
            String strIsDisabled = new String("");
            String strIsChecked = new String("");
            
            if(j%2 == 1){
              strClassType = "td-listrom";
            }else{                    
              strClassType = "";
            }
           if(!bHasChecked)
            {
              strIsChecked = "Checked";                       
              bHasChecked = true;            
              nDefaultDeptId = (Integer)(deptMap.get("deptid"));   
              nDefaultStatus = (Integer)(deptMap.get("status"));
              DefaultIsBottom = (String)deptMap.get("isbottom"); 
              if(deptMap.get("parentdeptid")!=null)
                 nParentDeptId = (Integer)(deptMap.get("parentdeptid"));      
            }                
            j++;     
          %>
           <tr onmouseover="this.className='tr-over'" onmouseout="this.className='<%=JspHelper.filterNull(strClassType)%>'"  onClick="javascript:radiotrue('dept<%=JspHelper.filterNull(j)%>');clickUserGroup('<%=JspHelper.filterNull( deptMap.get("deptid") )%>','<%=JspHelper.filterNull( deptMap.get("parentdeptid") )%>','<%=JspHelper.filterNull( deptMap.get("isbottom") )%>','<%=JspHelper.filterNull( deptMap.get("status") )%>')" class="<%=JspHelper.filterNull(strClassType)%>">
          
            <td width="5%">
              <input id="dept<%=JspHelper.filterNull(j )%>" type="radio" name="checkdept"  value=<%=JspHelper.filterNull( deptMap.get("deptid") )%> class="checkbox" <%=JspHelper.filterNull( strIsChecked)%> onClick="javascript:clickUserGroup('<%=JspHelper.filterNull( deptMap.get("deptid") )%>','<%=JspHelper.filterNull( deptMap.get("parentdeptid") )%>','<%=JspHelper.filterNull( deptMap.get("isbottom") )%>')">
            </td>
            <td width="12%" >&nbsp;<%=JspHelper.filterNull( deptMap.get("deptcode") )%></td>
            <td width="25%" >&nbsp;<%=JspHelper.filterNull( deptMap.get("deptname") )%></td>
            <td width="25%" >&nbsp;<oval:write name="dept" property="parentdeptname"/></td>
            <td >&nbsp;<%=JspHelper.filterNull( deptMap.get("deptdesc") )%></td>
            <td >&nbsp;<%=JspHelper.filterNull( deptMap.get("businessdeptdesc") )%></td>
            <td width="6%" >&nbsp;<%=JspHelper.filterNull( deptMap.get("statusname") )%></td>
          </tr>
          </logic:iterate>  
          <input type="hidden" name="deptid" value="<%=JspHelper.filterNull( nDefaultDeptId )%>">
          <input type="hidden" name="status" value="<%=JspHelper.filterNull( nDefaultStatus )%>">
          <input type="hidden" name="isBottom" value="<%=JspHelper.filterNull( DefaultIsBottom)%>">
          <input type="hidden" name="parentdeptid" value="<%=JspHelper.filterNull(nParentDeptId)%>">
        </tr>
        
      <% //--------------------------------------  flipping page --%>
      <%@ include file="/inc/SummaryAction.inc" %>
      </table>
      <table width="100%" cellspacing="0" cellpadding="0">
        <tr> 
          <td class="summary_top"></td>
        </tr>
        <tr> 
          <td class="td_center">
            <a onclick="parent.down.location.href='DeptEdit.jsp?<%= OvalTools.randomURL() %>&orgid=<oval:write name="orginfo" property="orgid"/>';"><custom:button type="1" label="L_New" imgsrc="new.gif" border="0" style="width:60" privilegeCode="MB-BM01"/></a>
            <a onclick="page_edit()"><custom:button type="1" label="L_Edit" imgsrc="edit.gif" border="0" style="width:60" privilegeCode="MB-BM02"/></a>
            <%--<a onclick="page_delete()"><custom:button type="1" label="L_Delete" imgsrc="delete.gif" border="0" style="width:60"/></a>--%>
            <a onclick="create_child()"><custom:button type="1" label="L_CreatSubDept" imgsrc="CreatSubDept.gif" border="0" privilegeCode="MB-BM03"/></a>
            <a onclick="exportExcel();"><custom:button type="1" label="L_Execcd" imgsrc="delete.gif" border="0" style="width:60"/>
          </td>
        </tr>
      </table>
    </td>
  </tr>
 </form>
</table>
</body>
</html>


